/**
 * \file logFile.h
 * \brief logFile class header
 * \author Marc Laval
 * \version 0.1
 * \date 10/2011
 *
 */

#include "defines.h"
#include "types.h"
#include <string.h>

#ifndef _LOGFILE_H_
#define _LOGFILE_H_

/*!
 * \class LogFile
 * \brief Allow to manipulate a logFile
 *
 * Open a (existing or not) logFile to store informations like errors, warning etc
 * Singleton class.
 */
class LogFile
{
public:
    enum LogType
    {
        ltInformation = 0,
        ltWarning = 1,
        ltError = 2
    }

    /*! \brief Instanciate a log file to save informations (errors, warning etc)
     *  \param filename Filename as string
     *
     * LogFile is a singleton classe, usable by any object in the application.
     * The goal is to make it accessible from anywhere in the application
     * to be able to record any usable information for debug.
     */
    LogFile(std::string filename);

    /*! \brief Standard destructor
     *   Close the file
     */
    ~LogFile();

    /*! \brief Static method to get the instance of LogFile class
     *  \return Pointer to the instance
     *  If there is no instance of the class, a new one is created.
     */
    static LogFile * getInstance();

    /*! \brief Save a message in the log file
     *  \param lt Type of the message
     *  \param msg String containing the message
     */
    void log(LogType lt, std::string msg)


private:
    /*! \brief Instance of the class */
    static LogFile * m_log;

    /*! \brief File used to store the logs */
    std::ofstream ouputfile;

    /*! \brief Array containing strings
     *  These strings are the correspondance for LogType
     *  For example ltWarning will be the string "Warning"
     */
    static std::string type_names[3];
}

#endif //_LOGFILE_H_

